package com.quo.service.impl;

import java.util.List;




import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.quo.entity.Customer;
import com.quo.entity.Customer2;

import com.quo.entity.CustomerUpdate;

import com.quo.entity.Dept;
import com.quo.entity.Emp;
import com.quo.entity.EmpRole;
import com.quo.entity.ProductSeries2;
import com.quo.mapper.CustomerMapper;
import com.quo.mapper.DeptMapper;
import com.quo.service.CustomerService;
import com.quo.service.DeptService;
import com.quo.utils.SqlSessionUtil;

/**
 * 
 * @author 韩宛廷
 *
 */
 
@Service("customerService")
public class CustomerServiceImpl implements CustomerService {
	@Autowired
	private CustomerMapper cmapper;
	
	/**
	 * 获取所有的顾客信息
	 * @return
	 */
	@Override
	public List<Customer2> getAll() {
		return cmapper.getAll();
	}
	
	/**
	 * 获取自己的所有的顾客信息
	 * @return
	 */
	@Override
	public List<Customer2> getAllByEno(int eno) {
		return cmapper.getAllByEno(eno);
	}
	
	/**
	 * 获取所有顾客的单个详细信息
	 * @return
	 */
	@Override
	public Customer getAllByCid(int cid) {
		return 	cmapper.getAllByCid(cid);
	}

	@Override
	public EmpRole getRidByEno(int eno) {
		// TODO Auto-generated method stub
		return cmapper.getRidByEno(eno);
	}
	
	//获取自己的单个顾客信息
	@Override
	public Customer getCustomerByEno(int eno,int cid) {
		
		return cmapper.getCustomerByEno(eno, cid);
	}


	//更新顾客信息（可以更新所有人的信息）
	@Override
	public boolean updateCustomerByCid(CustomerUpdate customer, int cid) {
		return cmapper.updateCustomerByCid(customer, cid)==1;
	}

	//更新顾客信息（只能更新他自己创建的顾客信息）
	@Override
	public boolean updateCustomerByEno(CustomerUpdate customer,int eno, int cid) {
		return cmapper.updateCustomerByEno(customer, eno, cid)==1;
	}

	@Override
	public boolean save(CustomerUpdate customer,int eno) {
		return	cmapper.save(customer, eno)==1;
	}

}
